home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17996 < prev    next >
Mailbox/MIME Entity  |  1996-08-05  |  1.5 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Newsgroup Content (archive/news) magic Supported
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file news text default
99% file C source text default
98% file C source, ASCII text default
100% checkBytes Printable ASCII default
100% dexmagic PrintFox/Pagefox WEAK default
100% perlTextCheck Likely Text (Perl) default
100% siegfried fmt/950 MIME Email (1.0) default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime message/news default



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 50 61 74 68 3a 20 68 65 | 72 61 2e 69 64 73 2d 73 |Path: he|ra.ids-s|
|00000010| 63 68 65 65 72 2e 64 65 | 21 6e 65 77 73 0a 46 72 |cheer.de|!news.Fr|
|00000020| 6f 6d 3a 20 53 74 65 66 | 61 6e 20 57 65 73 6e 65 |om: Stef|an Wesne|
|00000030| 72 20 3c 73 2e 77 65 73 | 6e 65 72 40 69 64 73 2d |r <s.wes|ner@ids-|
|00000040| 73 63 68 65 65 72 2e 64 | 65 3e 0a 4e 65 77 73 67 |scheer.d|e>.Newsg|
|00000050| 72 6f 75 70 73 3a 20 63 | 6f 6d 70 2e 6c 61 6e 67 |roups: c|omp.lang|
|00000060| 2e 63 2b 2b 0a 53 75 62 | 6a 65 63 74 3a 20 52 65 |.c++.Sub|ject: Re|
|00000070| 3a 20 56 61 72 69 61 62 | 6c 65 20 41 52 47 20 6c |: Variab|le ARG l|
|00000080| 69 73 74 20 28 6f 66 20 | 74 79 70 65 20 64 6f 75 |ist (of |type dou|
|00000090| 62 6c 65 29 3f 0a 44 61 | 74 65 3a 20 54 68 75 2c |ble)?.Da|te: Thu,|
|000000a0| 20 31 38 20 41 70 72 20 | 31 39 39 36 20 31 35 3a | 18 Apr |1996 15:|
|000000b0| 31 37 3a 35 30 20 2b 30 | 32 30 30 0a 4f 72 67 61 |17:50 +0|200.Orga|
|000000c0| 6e 69 7a 61 74 69 6f 6e | 3a 20 49 44 53 20 50 72 |nization|: IDS Pr|
|000000d0| 6f 66 2e 20 53 63 68 65 | 65 72 20 47 6d 62 48 0a |of. Sche|er GmbH.|
|000000e0| 4d 65 73 73 61 67 65 2d | 49 44 3a 20 3c 33 31 37 |Message-|ID: <317|
|000000f0| 36 34 30 46 45 2e 32 34 | 39 43 40 69 64 73 2d 73 |640FE.24|9C@ids-s|
|00000100| 63 68 65 65 72 2e 64 65 | 3e 0a 52 65 66 65 72 65 |cheer.de|>.Refere|
|00000110| 6e 63 65 73 3a 20 3c 34 | 6c 34 35 35 32 24 61 6c |nces: <4|l4552$al|
|00000120| 32 40 66 61 6c 63 6f 6e | 2e 63 63 73 2e 75 77 6f |2@falcon|.ccs.uwo|
|00000130| 2e 63 61 3e 0a 52 65 70 | 6c 79 2d 54 6f 3a 20 73 |.ca>.Rep|ly-To: s|
|00000140| 2e 77 65 73 6e 65 72 40 | 69 64 73 2d 73 63 68 65 |.wesner@|ids-sche|
|00000150| 65 72 2e 64 65 0a 4e 4e | 54 50 2d 50 6f 73 74 69 |er.de.NN|TP-Posti|
|00000160| 6e 67 2d 48 6f 73 74 3a | 20 70 63 67 31 34 30 2e |ng-Host:| pcg140.|
|00000170| 69 64 73 2d 73 63 68 65 | 65 72 2e 64 65 0a 4d 69 |ids-sche|er.de.Mi|
|00000180| 6d 65 2d 56 65 72 73 69 | 6f 6e 3a 20 31 2e 30 0a |me-Versi|on: 1.0.|
|00000190| 43 6f 6e 74 65 6e 74 2d | 54 79 70 65 3a 20 74 65 |Content-|Type: te|
|000001a0| 78 74 2f 70 6c 61 69 6e | 3b 20 63 68 61 72 73 65 |xt/plain|; charse|
|000001b0| 74 3d 75 73 2d 61 73 63 | 69 69 0a 43 6f 6e 74 65 |t=us-asc|ii.Conte|
|000001c0| 6e 74 2d 54 72 61 6e 73 | 66 65 72 2d 45 6e 63 6f |nt-Trans|fer-Enco|
|000001d0| 64 69 6e 67 3a 20 37 62 | 69 74 0a 58 2d 4d 61 69 |ding: 7b|it.X-Mai|
|000001e0| 6c 65 72 3a 20 4d 6f 7a | 69 6c 6c 61 20 33 2e 30 |ler: Moz|illa 3.0|
|000001f0| 42 32 20 28 57 69 6e 4e | 54 3b 20 49 29 0a 54 6f |B2 (WinN|T; I).To|
|00000200| 3a 20 53 68 61 72 6f 6e | 20 57 61 6e 67 20 3c 73 |: Sharon| Wang <s|
|00000210| 77 61 6e 67 31 40 6a 75 | 6c 69 61 6e 2e 75 77 6f |wang1@ju|lian.uwo|
|00000220| 2e 63 61 3e 0a 0a 53 68 | 61 72 6f 6e 20 57 61 6e |.ca>..Sh|aron Wan|
|00000230| 67 20 77 72 6f 74 65 3a | 0a 3e 20 0a 3e 20 49 27 |g wrote:|.> .> I'|
|00000240| 64 20 6c 69 6b 65 20 74 | 6f 20 6d 61 6b 65 20 61 |d like t|o make a|
|00000250| 20 76 65 63 74 6f 72 20 | 77 69 74 68 20 67 69 76 | vector |with giv|
|00000260| 65 6e 20 65 6c 65 6d 65 | 6e 74 73 2c 20 65 2e 67 |en eleme|nts, e.g|
|00000270| 2e 0a 3e 20 0a 3e 20 20 | 20 20 20 76 65 63 74 6f |..> .> | vecto|
|00000280| 72 20 75 28 31 2c 32 2c | 33 29 2c 20 75 28 31 2c |r u(1,2,|3), u(1,|
|00000290| 32 2c 33 2c 34 2c 35 29 | 3b 0a 3e 20 0a 3e 20 73 |2,3,4,5)|;.> .> s|
|000002a0| 6f 20 49 20 77 61 73 20 | 74 72 79 69 6e 67 20 74 |o I was |trying t|
|000002b0| 6f 20 75 73 65 20 76 61 | 5f 73 74 61 72 74 28 29 |o use va|_start()|
|000002c0| 20 61 6e 64 20 76 61 5f | 61 72 67 28 29 20 69 6e | and va_|arg() in|
|000002d0| 20 3c 73 74 64 61 72 67 | 2e 68 3e 2e 0a 3e 20 48 | <stdarg|.h>..> H|
|000002e0| 6f 77 65 76 65 72 2c 20 | 74 68 65 20 6d 61 6e 70 |owever, |the manp|
|000002f0| 61 67 65 20 66 6f 72 20 | 73 74 64 61 72 67 2e 68 |age for |stdarg.h|
|00000300| 20 61 6e 64 20 73 65 76 | 65 72 61 6c 20 43 2c 20 | and sev|eral C, |
|00000310| 43 2b 2b 20 62 69 62 6c | 65 73 20 67 69 76 65 0a |C++ bibl|es give.|
|00000320| 3e 20 6f 6e 6c 79 20 74 | 68 65 20 65 78 61 6d 70 |> only t|he examp|
|00000330| 6c 65 73 20 69 6e 20 77 | 68 69 63 68 2c 20 74 68 |les in w|hich, th|
|00000340| 65 20 61 72 67 75 6d 65 | 6e 74 20 6c 69 73 74 20 |e argume|nt list |
|00000350| 73 74 61 72 74 73 20 77 | 69 74 68 0a 3e 20 63 68 |starts w|ith.> ch|
|00000360| 61 72 20 2a 73 74 72 69 | 6e 67 2c 20 65 2e 67 2e |ar *stri|ng, e.g.|
|00000370| 20 70 72 69 6e 74 66 28 | 63 6f 6e 73 74 20 63 68 | printf(|const ch|
|00000380| 61 72 20 2a 66 6d 74 2c | 20 2e 2e 2e 29 2e 20 20 |ar *fmt,| ...). |
|00000390| 41 6e 79 62 6f 64 79 20 | 6b 6e 6f 77 0a 3e 20 68 |Anybody |know.> h|
|000003a0| 6f 77 20 74 6f 20 67 65 | 74 20 28 64 6f 75 62 6c |ow to ge|t (doubl|
|000003b0| 65 20 61 72 67 2c 20 2e | 2e 2e 29 20 77 6f 72 6b |e arg, .|..) work|
|000003c0| 3f 20 28 62 61 73 69 63 | 61 6c 6c 79 2c 20 68 6f |? (basic|ally, ho|
|000003d0| 77 20 74 6f 20 74 65 72 | 6d 69 6e 61 74 65 0a 3e |w to ter|minate.>|
|000003e0| 20 74 68 65 20 73 65 61 | 72 63 68 20 66 6f 72 20 | the sea|rch for |
|000003f0| 74 68 65 20 6c 61 73 74 | 20 61 72 67 20 69 6e 20 |the last| arg in |
|00000400| 74 68 65 20 6c 69 73 74 | 29 0a 3e 20 0a 3e 20 53 |the list|).> .> S|
|00000410| 68 61 72 6f 6e 0a 3e 20 | 3c 73 77 61 6e 67 31 40 |haron.> |<swang1@|
|00000420| 6a 75 6c 69 61 6e 2e 75 | 77 6f 2e 63 61 3e 0a 49 |julian.u|wo.ca>.I|
|00000430| 74 27 73 20 6e 6f 74 20 | 65 78 61 63 74 6c 79 20 |t's not |exactly |
|00000440| 77 68 61 74 20 79 6f 75 | 20 77 61 6e 74 20 74 6f |what you| want to|
|00000450| 20 64 6f 2c 20 62 61 74 | 20 69 20 74 68 69 6e 6b | do, bat| i think|
|00000460| 20 69 74 20 77 69 6c 6c | 20 68 65 6c 70 2e 20 54 | it will| help. T|
|00000470| 68 65 20 63 6f 6d 6d 6f | 6e 20 74 68 69 6e 67 20 |he commo|n thing |
|00000480| 74 6f 0a 64 65 74 65 72 | 6d 69 6e 65 20 74 68 65 |to.deter|mine the|
|00000490| 20 65 6e 64 20 6f 66 20 | 74 68 65 20 6c 69 73 74 | end of |the list|
|000004a0| 20 69 73 20 61 20 22 4e | 75 6c 6c 22 20 45 6c 65 | is a "N|ull" Ele|
|000004b0| 6d 65 6e 74 20 61 74 20 | 74 68 65 20 65 6e 64 2e |ment at |the end.|
|000004c0| 0a 0a 0a 23 69 6e 63 6c | 75 64 65 20 3c 73 74 64 |...#incl|ude <std|
|000004d0| 69 6f 2e 68 3e 0a 23 69 | 6e 63 6c 75 64 65 20 3c |io.h>.#i|nclude <|
|000004e0| 73 74 64 61 72 67 2e 68 | 3e 0a 0a 2f 2a 20 63 61 |stdarg.h|>../* ca|
|000004f0| 6c 63 75 6c 61 74 65 20 | 73 75 6d 20 6f 66 20 61 |lculate |sum of a|
|00000500| 20 30 20 74 65 72 6d 69 | 6e 61 74 65 64 20 6c 69 | 0 termi|nated li|
|00000510| 73 74 20 2a 2f 0a 76 6f | 69 64 20 73 75 6d 28 63 |st */.vo|id sum(c|
|00000520| 68 61 72 20 2a 6d 73 67 | 2c 20 2e 2e 2e 29 0a 7b |har *msg|, ...).{|
|00000530| 0a 20 20 20 69 6e 74 20 | 74 6f 74 61 6c 20 3d 20 |. int |total = |
|00000540| 30 3b 0a 20 20 20 76 61 | 5f 6c 69 73 74 20 61 70 |0;. va|_list ap|
|00000550| 3b 0a 20 20 20 69 6e 74 | 20 61 72 67 3b 0a 20 20 |;. int| arg;. |
|00000560| 20 76 61 5f 73 74 61 72 | 74 28 61 70 2c 20 6d 73 | va_star|t(ap, ms|
|00000570| 67 29 3b 0a 20 20 20 77 | 68 69 6c 65 20 28 28 61 |g);. w|hile ((a|
|00000580| 72 67 20 3d 20 76 61 5f | 61 72 67 28 61 70 2c 69 |rg = va_|arg(ap,i|
|00000590| 6e 74 29 29 20 21 3d 20 | 30 29 20 7b 0a 20 20 20 |nt)) != |0) {. |
|000005a0| 20 20 20 74 6f 74 61 6c | 20 2b 3d 20 61 72 67 3b | total| += arg;|
|000005b0| 0a 20 20 20 7d 0a 20 20 | 20 70 72 69 6e 74 66 28 |. }. | printf(|
|000005c0| 6d 73 67 2c 20 74 6f 74 | 61 6c 29 3b 0a 20 20 20 |msg, tot|al);. |
|000005d0| 76 61 5f 65 6e 64 28 61 | 70 29 3b 0a 7d 0a 0a 69 |va_end(a|p);.}..i|
|000005e0| 6e 74 20 6d 61 69 6e 28 | 76 6f 69 64 29 20 7b 0a |nt main(|void) {.|
|000005f0| 20 20 20 73 75 6d 28 22 | 54 68 65 20 74 6f 74 61 | sum("|The tota|
|00000600| 6c 20 6f 66 20 31 2b 32 | 2b 33 2b 34 20 69 73 20 |l of 1+2|+3+4 is |
|00000610| 25 64 5c 6e 22 2c 20 31 | 2c 32 2c 33 2c 34 2c 30 |%d\n", 1|,2,3,4,0|
|00000620| 29 3b 0a 20 20 20 72 65 | 74 75 72 6e 20 30 3b 0a |);. re|turn 0;.|
|00000630| 7d 0a | |}. | |
+--------+-------------------------+-------------------------+--------+--------+